package com.clh.util;

import java.util.regex.Pattern;

public class RegexUtil {

		/**
		 * 校验手机号是否合法
		 */
	public static boolean validatePhoneNumber(String phoneNumber) {
		//定义正则表达式
		String pattern="^[1][3,5,7,8]\\d{9}$";
		Boolean flag=Pattern.matches(pattern,phoneNumber);
		return flag;
	}
		/**
		 * 校验密码是否合法
		 */
	public static boolean validatePassword(String password) {
		//定义正则表达式
		String pattern="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$";
		Boolean flag=Pattern.matches(pattern,password);
		return flag;
	}
	
	/**
	 * 检验18位身份证是否合法
	 * @param ownerId
	 * @return
	 */
	public static boolean validateOwnerId(String ownerId) {
		String pattern = "^[1-9]\\d{5}((((19|[2-9][0-9])\\d{2})(0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|(((19|[2-9][0-9])\\d{2})(0[13456789]|1[012])(0[1-9]|[12][0-9]|30))|(((19|[2-9][0-9])\\d{2})02(0[1-9]|1[0-9]|2[0-8]))|(((1[6-9]|[2-9][0-9])(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))0229))\\d{3}[0-9Xx]$";
		Boolean flag=Pattern.matches(pattern, ownerId);
		return flag;
	}
}
